package com.chezhujie.www.service;

import com.chezhujie.www.core.page.Pagination;
import com.chezhujie.www.domain.Czjadvertisementimg2;
import com.chezhujie.www.persistence.Czjadvertisementimg2Mapper;
import com.chezhujie.www.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service("czjadvertisementimg2Service")
public class Czjadvertisementimg2Service {
	@Autowired
	private Czjadvertisementimg2Mapper czjadvertisementimg2Mapper;

	/**
	 * 查询某个czj_advertisementImg  图片广告
	 * @param param
	 * @return
	 */
	public Czjadvertisementimg2 getCzjadvertisementimg(Map<String,Object> param) {
		return czjadvertisementimg2Mapper.getCzjadvertisementimg(param);
	}
	
	/**
	 * 查询某个czj_advertisementImg  图片广告
	 * @param param
	 * @return
	 */
	public List<String> getCzjadvertisementimgALL() {
		return czjadvertisementimg2Mapper.getCzjadvertisementimgALL();
	}	
   
	/**
	 * 查询某个czj_advertisementImg  图片广告queryImgOrder
	 * @param param
	 * @return
	 */
	public Czjadvertisementimg2 queryImgOrder(Map<String,Object> param) {
		return czjadvertisementimg2Mapper.queryImgOrder(param);
	}	
	
	/**
	 * 查询czj_advertisementImg  图片广告列表
	 * @return
	 */
	public Map<String,Object> getCzjadvertisementimgList(Map<String,Object> param) {
		Map<String,Object> returnMap = new HashMap<String,Object>();
		returnMap.put("totalCounts", czjadvertisementimg2Mapper.getTotalRows(param));
		returnMap.put("list", czjadvertisementimg2Mapper.getCzjadvertisementimgList(param));
		return returnMap;
	}
   
	
	/**
	 * 查询czj_advertisementImg  图片广告列表
	 * @return
	 */
	public  List<Czjadvertisementimg2> getCzjadvertisementimgListALL(Map<String,Object> param) {
		List<Czjadvertisementimg2> list=	czjadvertisementimg2Mapper.getCzjadvertisementimgListALL(param);
		return list;
		
	}	
	
	
	
	/**
	 * 查询czj_advertisementImg  图片广告列表
	 * @return
	 */
	public  Pagination getCzjadvertisementimgList(Map<String,Object> param,int pageSize,Integer pageNo,String order,String sort) {
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		p.setOrder(order);
		p.setSort(sort);
		param.putAll(p.toMap());
		int count=czjadvertisementimg2Mapper.getTotalRows(param);
		List<Czjadvertisementimg2> list=	czjadvertisementimg2Mapper.getCzjadvertisementimgList(param);
	
		p.setList(list);
		p.setTotalCount(count);
		return p;
		
	}
      
	/**
	 * 新增czj_advertisementImg  图片广告
	 * @param czjadvertisementimg
	 * @param param
	 */
	@Transactional
	public void insertCzjadvertisementimg(Czjadvertisementimg2 czjadvertisementimg) {
		czjadvertisementimg.setAdvertisementId(UUIDUtils.getUUID());
		czjadvertisementimg2Mapper.insertCzjadvertisementimg(czjadvertisementimg);
	}
   
	/**
	 * 编辑czj_advertisementImg  图片广告
	 * @param czjadvertisementimg
	 * @param param
	 */
	@Transactional
	public void updateCzjadvertisementimg(Czjadvertisementimg2 czjadvertisementimg) {
		czjadvertisementimg2Mapper.updateCzjadvertisementimg(czjadvertisementimg);
	}
   
	/**
	 * 删除czj_advertisementImg  图片广告
	 * @param param
	 */    
	@Transactional
	public void deleteCzjadvertisementimg(List<String> advertisementIdList) {
		for(String advertisementId: advertisementIdList){
	  		Map<String,Object> param = new HashMap<String,Object>();
	  		param.put("advertisementId", advertisementId);
	 	   czjadvertisementimg2Mapper.deleteCzjadvertisementimg(param);
		}
	}


}